<?php
include_once("../configure/admin.config.inc.php");//--> admin global var
include_once("account.inc.php");				//--> account var
include_once("db.inc.php");						//--> db global var
include_once("Operation.php");					//--> Operation
include_once("Users.php");						//--> Users
include_once("Account.php");					//--> Account
include_once("AccountLog.php");					//--> AccountLog
require_once("controlHeader.php");				//--> system control header

$objOperate	= new Operation($sessionImpl->getLanguage());	//--> Operation instance
$objUsers	= new Users($uid);								//--> Users
$objAccount	= new Account($uid);							//--> Account
$objAccountLog	= new AccountLog($uid);						//--> AccountLog

$arrOperate = $objOperate->arrGetFromGroupIDAndMenuID($gid, $menuid);

if(isset($_GET['id']) && !empty($_GET['id'])){
	$id = $_GET['id'];

	$isReturn = $objUsers->editStatus($arrOperate, $id, "normal");
	if($isReturn){
		$error_message = 'Live successfully.';
		
		//$amount = $objAccountLog->fetchSumCounting($arrOperate, SOURCE_USER, $id);
		//echo 'a='.$amount;
		$amount = $objAccountLog->isExistOperate($arrOperate, $id, SOURCE_USER, $id, SOURCE_TYPE_ADD);
		if($amount <= 0)
			$objAccount->addAccounting($arrOperate, DEFAULT_LAN, $uid, $id, DEFAULT_USER_ADD_BALANCE, SOURCE_USER, $id, SOURCE_TYPE_ADD, $_SERVER['REMOTE_ADDR']);
	}else 
		$error_message = 'Live failure.';
}

echo "<script language='javascript'>";
echo "alert(\"$error_message\");";
echo "location.href=\"".$_SERVER['HTTP_REFERER']."\";";
echo "</script>";

//$backurl = $_SERVER['HTTP_REFERER'];
//header("Location: $backurl");
?>
